//json
//获取用户车辆信息和去年投保信息
function main(tbl){
	let url="http://iu.91bihu.com/api/CarInsurance/getreinfo";
	if(isEmpty(tbl.LicenseNo)&&(isEmpty(tbl.CarVin)||isEmpty(tbl.EngineNo))){
		return {code:1101,msg:"车牌号LicenseNo不能为空"}
	}
	if(isEmpty(tbl.CityCode)){
		return {code:1101,msg:"城市码CityCode不能为空"}
	}
	tbl.remove("appid")
	tbl.remove("appkey")
	let u=attr("u")
	let lang="en";
	if(!isEmpty(tbl.lang)){
		lang=tbl.lang;
	}
	let time1=System.currentTimeMillis();
	let res={}
	let reqres="请求成功"
		let resmsg="查询成功"
	let tb=dao.fetch("app_tb",Cnd.where("tbl","=",tbl.tourl()))
	if(tb!=null){
		res= baozhuang(tb.result,lang);
	}else{
		let mp=new JseMap(tbl);
		mp.put("Group", "1");
		mp.put("Agent", "168307");
		mp.put("CustKey", "bihu520521");
		let secCode=Lang.md5(mp.tourl()+"852600cf81f");
		mp.put("SecCode", secCode);
		let text=Http.get(url,mp,60000).getContent();
		res=foJson(text);
		if(isEmpty(res.UserInfo)){
			resmsg="查无数据"
			res.code=404;
			res.msg=resmsg;
		}else{
			resmsg="查询成功"
			res.code=200;
			let tab=new Record();
			tab.put(".table","app_tb")
			tab.put("type",tbl.id)
			tab.put("tbl",tbl.tourl())
			tab.put("result",text)
			dao.insert(tab)
		}
		res= baozhuang(res,lang);
	}
	let time2=System.currentTimeMillis();
	let time3=(time2-time1)+1;
	let tab=new Record();
	tab.put(".table","app_log")
	tab.put("username",u.username)
	tab.put("ms",time3)
	tab.put("uid",u.id)
	tab.put("type",u.type)
	tab.put("ip",ip())
	tab.put("reqres",reqres)
	tab.put("resmsg",resmsg)
	tab.put("param",tbl.tourl())
	$save(tab)
	if(resmsg=="查询成功"){
		$update({".table":"app_buy","cxnum":u.cxnum+1,"id":u.bid})
	}
	return res;
}
var dicts={
		"UserInfo": {
			"CarUsedType": "使用性质",
			"LicenseNo": "车牌号",
			"LicenseOwner": "车主姓名",
			"InsuredName": "投保人",
			"PostedName": "被保险人",
			"IdType": "证件类型",
			"CredentislasNum": "证件号码",
			"CityCode": "城市Id",
			"EngineNo": "发动机号",
			"ModleName": "品牌型号",
			"CarVin": "识别代号",
			"RegisterDate": "注册日期",
			"ForceExpireDate": "强险到期",
			"BusinessExpireDate": "商业险到期",
			"NextForceStartDate": "交强起保日期",
			"NextBusinessStartDate": "商业险起保日期",
			"PurchasePrice": "购置价格",
			"SeatCount": "座位数量",
			"FuelType": "燃料种类",
			"ProofType": "来历凭证",
			"LicenseColor": "号牌底色",
			"ClauseType": "条款类型 ",
			"RunRegion": "行驶区域",
			"InsuredIdCard": "被保人证件号",
			"InsuredIdType": "被保人证件类型",
			"InsuredMobile": "被保人手机号",
			"HolderIdCard": "投保人证件号",
			"HolderIdType": "投保人证件类型",
			"HolderMobile": "投保人联系方式",
			"RateFactor1": "无赔款系数",
			"RateFactor2": "自主渠道系数",
			"RateFactor3": "自主核保系数",
			"RateFactor4": "违法浮动系数",
			"IsPublic": "属性",
			"BizNo": "商业险保单号",
			"ForceNo": "交强险保单号",
			"AutoMoldCode": "精友码",
			"ExhaustScale": "排量信息",
			"Organization": "组织机构名称"
		},
		"SaveQuote": {
			"Source": "保险公司",
			"CheSun": "车损保额",
			"SanZhe": "责任险保额",
			"DaoQiang": "盗抢保额",
			"SiJi": "司机保额",
			"ChengKe": "乘客保额",
			"BoLi": "玻璃保额",
			"HuaHen": "划痕保额",
			"SheShui": "涉水保额",
			"ZiRan": "自燃保额",
			"BuJiMianCheSun": "不计免车损",
			"BuJiMianSanZhe": "不计免三者",
			"BuJiMianDaoQiang": "不计免盗抢",
			"BuJiMianChengKe": "不计免乘客",
			"BuJiMianSiJi": "不计免司机",
			"BuJiMianHuaHen": "不计免划痕保额",
			"BuJiMianSheShui": "不计免涉水",
			"BuJiMianZiRan": "不计免自燃",
			"BuJiMianJingShenSunShi": "不计免精神",
			"HcSanFangTeYue": "特约保额",
			"HcJingShenSunShi": "精神损失",
			"HcXiuLiChang": "修理厂险",
			"HcXiuLiChangType": "修理厂类型",
			"Fybc": "修理期每天",
			"FybcDays": "天数",
			"SheBeiSunShi": "设备损失",
			"BjmSheBeiSunShi": "不计免设备",
			"SheBeis": "设备列表"
		},
		"BusinessStatus":"信息状态",
		"StatusMessage":"信息描述"
	}

function baozhuang(res,lang){
	if(isEmpty(res.code)){
		res.code=200;
	}
	delete res.CustKey
	if(lang=="cn"){
		let resmp1=new JseMap();
		let resmp2=new JseMap();
	for(var item in res.UserInfo){
		if(dicts["UserInfo"][item]!=null){
			resmp1.put(dicts["UserInfo"][item],res.UserInfo[item])
		}else{
			resmp1.put(item,res.UserInfo[item])
		}
	}
		res.UserInfo=resmp1;
		for(var item in res.SaveQuote){
			if(dicts["SaveQuote"][item]!=null){
				resmp2.put(dicts["SaveQuote"][item],res.SaveQuote[item])
			}else{
				resmp2.put(item,res.SaveQuote[item])
			}
		}
			res.SaveQuote=resmp2;
			/*res[dicts["BusinessStatus"]]=res.BusinessStatus;
			res[dicts["StatusMessage"]]=res.StatusMessage;
			delete res.BusinessStatus
			delete res.StatusMessage*/
	}
	return res;
}